package com.gitee.gateway.core.db;

import io.vertx.core.json.JsonArray;
import org.jdbi.v3.core.argument.AbstractArgumentFactory;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.config.ConfigRegistry;

import java.sql.Types;

public class JsonArrayArgumentFactory extends AbstractArgumentFactory<JsonArray> {

    public JsonArrayArgumentFactory() {
        super(Types.VARCHAR);
    }

    @Override
    protected Argument build(JsonArray value, ConfigRegistry config) {
        return ((position, statement, ctx) -> statement.setString(position, value.encode()));
    }
}

